/**
 * @Project TMHSC
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Feb 25, 2011
 * @Createtime 1:43:00 PM
 */

package com.tmh.study.aS3DP.mcv.minimalist
{
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.KeyboardEvent;

	public class View
	{
		private var _model:IModel;

		private var _controller:IKeyboardInputHandler;

		public function View(model:IModel, controller:IKeyboardInputHandler, target:Stage)
		{
			_model = model;
			_controller = controller;

			_model.addEventListener(Event.CHANGE, update);
			target.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress);
		}

		private function update(event:Event):void
		{
			trace(_model.getKey());
		}

		private function onKeyPress(event:KeyboardEvent):void
		{
			_controller.keyPressHandler(event);
		}
	}
}